Sql : Postgresql Select Max With Group By And Additional Value